Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cron): add support for "*/n" interval cronjob syntax #2360

Merged
merged 13 commits into from
Jun 14, 2024

Conversation

kinoute
Copy link
Contributor

@kinoute kinoute commented Jun 9, 2024

Currently KVRocks only supports integers and * in crontab format. I thought it would be nice to add support for the */n interval syntax. I understand that we can already add multiple crontab entries for the same feature like this:

bgsave-cron 0 3 * * * 0 6 * * * (and more...)

But it would be convenient if we could do something like this instead:

bgsave-cron 0 */3 * * *

Again, I'm new to C++ so no offense taken if the code provided is not good at all for your standards. The "month" part was a pain to do and I'm not sure about it. I used https://crontab.guru/#0_*_*_*/4_* to calibrate my code/tests for this.

@kinoute kinoute changed the title Add support for "*/n" interval cronjob syntax feat(cron): add support for "*/n" interval cronjob syntax Jun 9, 2024
kvrocks.conf Outdated Show resolved Hide resolved
src/common/cron.cc Outdated Show resolved Hide resolved
src/common/cron.cc Outdated Show resolved Hide resolved
@kinoute
Copy link
Contributor Author

kinoute commented Jun 10, 2024

@PragmaTwice Thanks for your suggestions, I updated the code

src/common/cron.cc Outdated Show resolved Hide resolved
src/common/cron.cc Outdated Show resolved Hide resolved
src/common/cron.cc Outdated Show resolved Hide resolved
@kinoute
Copy link
Contributor Author

kinoute commented Jun 11, 2024

@PragmaTwice Thanks, updated again the code

src/common/cron.cc Outdated Show resolved Hide resolved
src/common/cron.cc Outdated Show resolved Hide resolved
src/common/cron.cc Outdated Show resolved Hide resolved
@kinoute
Copy link
Contributor Author

kinoute commented Jun 12, 2024

I added more tests for non interval syntax and renamed the min_val parameter

src/common/cron.cc Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented Jun 13, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@git-hulk git-hulk merged commit 93c8dc2 into apache:unstable Jun 14, 2024
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants